package microarray;

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.TreeMap;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class Summary  implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -5104228410779889014L;
	@PrimaryKey
	@Persistent
	private String id;
	@Persistent
	private Map<String, String> items;
	@Persistent
	private Map<String, String> samples;
	@Persistent
	private LinkedList<String> authors;
	
	public Summary(){
		items = new HashMap<String, String>(); // name, value
		samples = new TreeMap<String, String>(); //accession, title
		authors = new LinkedList<String>();
	}
	
	public LinkedList<String> getAuthors() {
		return authors;
	}

	public void addAuthor(String author) {
		this.authors.add(author);
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}
	
	public void addItem(String key, String value) {
		this.items.put(key.toLowerCase(), value);
	}
	public String getItem(String key) {
		if (this.items.containsKey(key.toLowerCase()))
			return this.items.get(key.toLowerCase());
		else 
			return key + " not found";
	}

	public Map<String, String> getItems() {
		return items;
	}

	public void setSamples(Map<String, String> samples) {
		this.samples = samples;
	}
	
	public void addSample(String key, String value) {
		this.samples.put(key, value);
	}

	public Map<String, String> getSamples() {
		return samples;
	}
	
	public String toString()
	{
		String value = id + ":";
		value += "\nTitle: " + items.get("title");
		value += "\nDescription: " + items.get("description");
		return value;
	}
	
	
}



